#@head() #@header()
<title>客户列表</title>
#@aside("user")
<script type="text/javascript" src="#(path)/assets/js/jquery.tmpl.min.js"></script>
<style>
	.box-body{padding:5px !important}
</style>
<div class="content-wrapper">
	<section class="content">
	<div class="nav-tabs-custom">
		#@usermenu("czjl")
		
		<div class="tab-content">
		  <div class="tab-pane active" id="tab_1">
				<div class="box-body">
				<label style="float:left;margin-top:8px;margin-left:5px;">起止时间：</label>
				<input id="createTimeStart" style="width:120px;float:left" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" type="text" class="form-control" placeholder="">
				<label style="float:left;margin-top:8px;">—</label>
                <input id="createTimeEnd" style="width:120px;float:left" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" type="text" class="form-control" placeholder="">

				<label style="float:left;margin-top:8px;margin-left:5px;">状态：</label>
				<select id="status2" style="width:120px;float:left" class="form-control">
					<option value="">全部</option>
					<option value="success">成功</option>
					<option value="process">进行中</option>
					<option value="error">失败</option>
				</select>
				<div class="col-xs-1">
				  <button id="seachuser" type="button" class="btn btn-info btn-flat">搜索</button>
				</div>

            </div>
			<div class="box-body">
				<table  id="example1" class="table table-striped">
					<thead>
						<tr>
							<th>序号</th>
							<th>真实姓名</th>
							<th>手机号</th>
							<th>交易类别</th>
							<th>金额（元）</th>
							<th>时间</th>
							<th>状态</th>
							<th>备注</th>
						</tr>
					</thead>
					<tbody id="userlist">
						
					</tbody>
				</table>
				<div class="box-footer clearfix">
				  <ul class="pagination pagination-sm no-margin pull-right">
					<li id="userlist1"><a href="#">首页</a></li>
					<li id="userlist2"><a href="#">上一页</a></li>
					<li><a href="#">第<span id="userlist5"></span>页 共<span id="userlist6"></span>页</a></li>
					<li id="userlist3"><a href="#">下一页</a></li>
					<li id="userlist4"><a href="#">尾页</a></li>
				  </ul>
				</div>
			</div>
			</div>
		</div>
	</div>
	</section>
</div>
#@footer()
<script id="userlistall" type="text/x-jquery-tmpl">
	<tr>
		<td>${id}</td>
		<td>${real_name}</td>
		<td>${mobile}</td>
		<td>${type}</td>
		<td><span style="color:${color}">${fuhao}￥${amount} 元</span></td>
		<td>${create_time}</td>
		<td>${status}</td>
		<td>${summary}</td>
	</tr>
</script>
<script>
var totalPage = 1;
var pageNumber = 1;

var createTimeStart='';
var createTimeEnd='';
var status2='';
$(document).ready(function(){
	pageNumber = 1;
	$("#userlist").empty();
	userlist(pageNumber,createTimeStart,createTimeEnd,status2);
	$("#userlist5").html(pageNumber);
	
});
$("#userlist1").click(function(){
	$("#userlist").empty();
	pageNumber==1
	userlist(pageNumber,createTimeStart,createTimeEnd,status2);
	$("#userlist5").html(pageNumber);
});
$("#userlist2").click(function(){
	if(pageNumber<=1){
		alert("当前页是首页!");
	}else{
	$("#userlist").empty();
	pageNumber = pageNumber-1;
	userlist(pageNumber,createTimeStart,createTimeEnd,status2);
	$("#userlist5").html(pageNumber);
	}
});
$("#userlist3").click(function(){
	if(pageNumber>=totalPage){
		alert("当前页是尾页!");
	}else{
	$("#userlist").empty();
	pageNumber = pageNumber +1;
	userlist(pageNumber,createTimeStart,createTimeEnd,status2);
	$("#userlist5").html(pageNumber);
	}
});
$("#userlist4").click(function(){
	$("#userlist").empty();
	pageNumber = totalPage;
	userlist(pageNumber,createTimeStart,createTimeEnd,status2);
	$("#userlist5").html(pageNumber);
});
$("#seachuser").click(function(){
	$("#userlist").empty();
	mobile2 = $("#mobile2").val();
	createTimeStart = $("#createTimeStart").val();
	createTimeEnd = $("#createTimeEnd").val();
	status2 = $("#status2").val();
	pageNumber = 1;
	userlist(pageNumber,createTimeStart,createTimeEnd,status2);
	$("#userlist5").html(pageNumber);
}); 

function userlist(pageNumber,createTimeStart,createTimeEnd,status2){
	url = "#(path)/investLog/list?token=#(session.token??)&page="+pageNumber+"&size=15&createTimeStart="+createTimeStart+"&createTimeEnd="+createTimeEnd+"&status="+status2+"&userId="+id.id;
	$.getJSON(url, function(userli) {
		 console.log(userli);
		totalPage = userli.data.page.totalPage;
		$("#userlist6").html(totalPage);
		$.each(userli.data.page.list, function(i, item){ 
			var status ="";
			var summary = item.summary;
			if(summary=="tzhb"){
				summary = "使用返现券"+item.amount+"元";
			}
			if(item.status == "success"){
				var dzje = item.real_amount;}else {
				var dzje =0;
			} 
			if(item.status == "success"){
				status = "成功";
			}else if(
				item.status == "failed"){
				status = "失败";
			} else if(item.status == "process"){
				status = "进行中";
			}
			if(item.type == "trade"){
				var type = "投资";
			}else if (item.type == "withdraw_fee"){
				var type = "提现手续费";
			}else if (item.type == "withdraw"){
				var type = "提现";
			}else if (item.type == "deposit_fee"){
				var type = "充值手续费";
			}else if (item.type == "deposit"){
				var type = "充值";
			}else if (item.type == "amount"){
				var type = "还款";
				var summary = $.parseJSON(item.summary);
				var summary = "本金还款："+summary.amount+"元 "+" 加息券："+summary.jxq+"元 "+" 平台加息："+ summary.plus + "元 " + "利息："+summary.interest+"元";
			}else if (item.type == "share"){
				var type = "分润";
				if(item.summary=="agent"){
					var summary = "客服分润";
				}
				if(item.summary=="tzhb"){
					var summary = "返现券分润";
				}
			}else if (item.type == "xjhb"){
				var type = "现金奖励";
			}else if (item.type == "tyj"){
				var type = "体验金";
			}
			if(item.mode=="sub"){
				var fuhao = "-";
				var color = "#000";
			}else if(item.mode =="add"){
				var fuhao = "+"
				var color = "#FF0000";
			}
			var userlist = {fuhao:fuhao,color:color,type:type,mobile:item.user.mobile,real_name:item.user.real_name,summary:summary,dzje:dzje,id:item.id,code:item.code,amount:item.amount,create_time:item.create_time,status:status};
			$("#userlistall").tmpl(userlist).appendTo('#userlist');
		});
	});	
}


</script>
</body>
</html>